<!doctype html>
{% extends "base.html" %}
{% block title %}Monit监控{% endblock title %}

{% block page3_show %}show{% endblock page3_show %}
{% block page3.3_active %}active{% endblock page3.3_active %}

{% block main_content %}
<div class="row">
{% for host,data in MonitData.data.items %}
<div class="col-12 col-lg-6">
    <div class="card">
        <div class="card-header">
            <h5 class="card-title">主机:{{ host }}</h5>
            <a href="" data-toggle="modal" data-target="#add_{{ host }}"><i class="fe fe-plus-circle float-right"></i></a>
            <ul class="nav nav-tabs card-header-tabs pull-right" role="tablist">
                {% for ItemName,Item in data.datadict.items %}
                    <li class="nav-item">
                        <a class="nav-link {{ Item.active }}" data-toggle="tab" href="#tab-{{host}}-{{ forloop.counter }}">{{ ItemName }}</a>
                    </li>
                {% endfor %}
            </ul>
            <div class="modal fade" id="add_{{ host }}" tabindex="-1" role="dialog" aria-hidden="true">
    			<div class="modal-dialog modal-dialog-centered" role="document">
    				<div class="modal-content">
    					<div class="modal-header">
    						<h1 class="modal-title">新增monit</h1>
    						<button type="button" class="close" data-dismiss="modal" aria-label="Close">
    		                    <span aria-hidden="true">&times;</span>
    		                  </button>
    					</div>
                        <form method="post" action="/MonitAdd">
    					<div class="modal-body m-3">
                            <div class="form-group row">
                                <label class="col-form-label col-sm-4 text-sm-right">所属主机</label>
                                <div class="col-sm-8">
                                    <input type="text" name="hostname" value="{{ host }}" readonly="readonly" class="form-control">
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-form-label col-sm-4 text-sm-right">监控进程名</label>
                                <div class="col-sm-8">
                                    <input type="text" name="process" required="" class="form-control">
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-form-label col-sm-4 text-sm-right">PID文件绝对路径</label>
                                <div class="col-sm-8">
                                    <input type="text" name="pidfile" required="" class="form-control">
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-form-label col-sm-4 text-sm-right">启动命令</label>
                                <div class="col-sm-8">
                                    <input type="text" name="start" required="" class="form-control">
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-form-label col-sm-4 text-sm-right">停止命令</label>
                                <div class="col-sm-8">
                                    <input type="text" name="stop" required="" class="form-control">
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-form-label col-sm-4 text-sm-right">条件：</label>
                                <div class="col-sm-8">
                                    <input type="text" name="context" required="" class="form-control">
                                </div>
                            </div>
    					</div>
    					<div class="modal-footer">
    						<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
    						<button type="submit" class="btn btn-primary">确定</button>
    					</div>
                        </form>
    				</div>
    			</div>
    		</div>
        </div>
        <div class="card-body">
            <div class="tab-content">
            {% for ItemName,Item in data.datadict.items %}
                <div class="tab-pane fade {{ Item.show }}" id="tab-{{host}}-{{ forloop.counter }}" role="tabpanel">
                    <h5 class="card-title">{{ ItemName }}的状态</h5>
                    <pre>{{ Item.res | linebreaks }}</pre>
                </div>
            {% endfor %}
            </div>
        </div>
    </div>
</div>
{% endfor %}
</div>
{% endblock main_content %}

{% block script %}
{% endblock script %}